package com.fmdj.dr.controller;

import cn.hutool.core.bean.BeanUtil;
import com.fmdj.common.util.CommonResult;
import com.fmdj.dr.controller.form.SelectDriverSettingsForm;
import com.fmdj.dr.controller.form.TransferForm;
import com.fmdj.dr.db.pojo.WalletIncomeEntity;
import com.fmdj.dr.service.WalletIncomeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.HashMap;

@RestController
@RequestMapping("/wallet/income")
@Tag(name = "DriverSettingsController", description = "司机设置模块接口")
@Slf4j
public class WalletIncomeController {

    @Autowired
    private WalletIncomeService walletIncomeService;

    @PostMapping("/transfer")
    @Operation(summary = "向司机钱包转账")
    public CommonResult transfer(@RequestBody @Valid TransferForm form) {
        WalletIncomeEntity walletIncomeEntity = BeanUtil.toBean(form, WalletIncomeEntity.class);
        walletIncomeEntity.setStatus((byte)3);
        int rows = walletIncomeService.transfer(walletIncomeEntity);
        return CommonResult.ok().put("rows", rows);
    }

}
